﻿using System;
using System.Collections.Generic;
using NHibernate;
using NHibernate.Cfg;

namespace EasyExam.DataServer.NHB
{
    public sealed class NHibernateHelper
    {
        private static readonly ISessionFactory sessionFactory;

        static NHibernateHelper()
        {
            try
            {
                sessionFactory = new Configuration().Configure().BuildSessionFactory();
            }
            catch (Exception ex)
            {
            }
        }

        public static ISession GetCurrentSession()
        {
            return sessionFactory.OpenSession();
        }

        public static void CloseSessionFactory()
        {
            if (sessionFactory != null)
            {
                sessionFactory.Close();
            }
        }
    }

}
